﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace h1
{
    public partial class Form_details : Form
    {
        public Form_details()
        {
            InitializeComponent();
        }
        public Form_details(int tabel,string ID)
        {
            InitializeComponent();
            using (var sq = new Sqlite())
            {
                //object selectedItem;
                switch(tabel)
                {
                    case 0:
                        School seSchool = sq.Schools.SingleOrDefault(b=>b.SchoolID==ID);
                        if (seSchool.SchoolID != null)
                        {
                            treeView1.Nodes.Add("SchoolID");
                            treeView1.Nodes[treeView1.Nodes.Count-1].Nodes.Add(seSchool.SchoolID);
                        }
                        break;
                    case 1:
                        Class seClass = sq.Classes.SingleOrDefault(b => b.ClassID == ID) as Class;
                        break;
                    case 2:
                        Student seStudent = sq.Students.SingleOrDefault(b => b.StudentID == ID) as Student;
                        break;
                    default:
                        School seSchooll = sq.Schools.SingleOrDefault(b => b.SchoolID == ID) as School;
                        break;
                }
                
            }
        }

        private void Form_details_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
